home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / Procedural / AMReminder / MainWindow.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-19  |  5.5 KB  |  251 lines  |  [TEXT/MMCC]

  1. /* MainWindow.c */
  2. /* Created 01/01/95 12:01 PM by AppMaker */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Dialogs.h>
  8. #include <Events.h>
  9. #include <Lists.h>
  10. #include <Menus.h>
  11. #include <Resources.h>
  12. #include <TextEdit.h>
  13. #include <ToolUtils.h>
  14. #include "ResourceDefs.h"
  15. #include "Globals.h"
  16. #include "Miscellany.h"
  17. #include "Scrolling.h"
  18. #include "WindowAids.h"
  19. #include "AMReminderData.h"
  20. #include "Add.h"
  21. #include "MainWindow.h"
  22.  
  23. #define LogoPicture        1
  24. #define YearLabel        2
  25. #define RemindersLabelLabel        3
  26. #define RemindersList        4
  27. #define AddButton        5
  28. #define EditButton        6
  29. #define DeleteButton        7
  30.  
  31. static void BuildRemindersList    (void);
  32. static void DoAddButton (void);
  33. static void DoEditButton (void);
  34. static void DoDeleteButton (void);
  35.  
  36. /*----------*/
  37. static void BuildRemindersList    ()
  38. {
  39.     Rect            bounds;
  40.  
  41.     SetWFont (RemindersList);
  42.     GetWRect (RemindersList, &bounds);
  43.     cur->RemindersHandle = NewV1List (bounds, qd.thePort);
  44.     AddToList ("\pOne",   cur->RemindersHandle);
  45.     AddToList ("\pTwo",   cur->RemindersHandle);
  46.     AddToList ("\pThree", cur->RemindersHandle);
  47.     AddToList ("\pInfinity",  cur->RemindersHandle);
  48.     LDoDraw (true, cur->RemindersHandle);
  49.  
  50. } /*BuildRemindersList*/
  51.  
  52. /*----------*/
  53. static void DoAddButton ()
  54. {
  55.     AddRec                AddInfo;
  56.     register AddRecPtr    info;
  57.  
  58.     info = &AddInfo;
  59.     /*initialize Add info*/
  60.     info->LogoData = nil;
  61.     info->DateText [0] = 0;
  62.     info->TimeText [0] = 0;
  63.     info->AmPmChoice = 1;
  64.     info->MessageText [0] = 0;
  65.     info->DisplayIconChecked = false;
  66.     info->DisplayAlertChecked = false;
  67.     info->PlaySoundChecked = false;
  68.     info->SoundChoice = 1;
  69.  
  70.     if (GetAdd (&AddInfo)) {
  71.         /*use Add info*/
  72.     }
  73. } /*DoAddButton*/
  74.  
  75. /*----------*/
  76. static void DoEditButton ()
  77. {
  78.     AddRec                AddInfo;
  79.     register AddRecPtr    info;
  80.  
  81.     info = &AddInfo;
  82.     /*initialize Add info*/
  83.     info->LogoData = nil;
  84.     info->DateText [0] = 0;
  85.     info->TimeText [0] = 0;
  86.     info->AmPmChoice = 1;
  87.     info->MessageText [0] = 0;
  88.     info->DisplayIconChecked = false;
  89.     info->DisplayAlertChecked = false;
  90.     info->PlaySoundChecked = false;
  91.     info->SoundChoice = 1;
  92.  
  93.     if (GetAdd (&AddInfo)) {
  94.         /*use Add info*/
  95.     }
  96. } /*DoEditButton*/
  97.  
  98. /*----------*/
  99. static void DoDeleteButton ()
  100. {
  101. } /*DoDeleteButton*/
  102.  
  103. /*----------*/
  104. void OpenMainWindow    (FSSpec*    fileSpec,
  105.                          short        fRefNum)
  106. {
  107.     WindowPtr        newWindow;
  108.     Rect            bounds;
  109.  
  110.     newWindow = GetWindow (WIND_MainWindow);
  111.     if (fileSpec->name [0] != 0) {
  112.         SetWTitle (newWindow, fileSpec->name);
  113.     }
  114.     SetPort (newWindow);
  115.     SetNewInfo (newWindow);
  116.     cur->vScroll = nil;
  117.     cur->hScroll = nil;
  118.     cur->fileNum    = fRefNum;
  119.     cur->dirty        = false;
  120.     cur->filename    = NewString (fileSpec->name);
  121.     cur->windowKind = WMainWindow;
  122.     ((WindowPeek) curWindow)->windowKind = userKind + WMainWindow;
  123.     cur->witlHandle = GetResource ('Witl', WIND_MainWindow);
  124.     cur->wictHandle = GetResource ('Wict', WIND_MainWindow);
  125.  
  126.     BuildRemindersList ();
  127.     cur->AddHandle = GetNewControl (CNTL_Add, newWindow);
  128.     cur->EditHandle = GetNewControl (CNTL_Edit, newWindow);
  129.     cur->DeleteHandle = GetNewControl (CNTL_Delete, newWindow);
  130.     cur->text = nil;
  131.  
  132.     ShowWindow (newWindow);
  133.  
  134. } /*OpenMainWindow*/
  135.  
  136. /*----------*/
  137. void CloseMainWindow    (void)
  138. {
  139.     LDispose (cur->RemindersHandle);
  140.  
  141.     DisposHandle ((Handle) cur->filename);
  142.     DiscardInfo (curWindow);
  143. } /*CloseMainWindow*/
  144.  
  145. /*----------*/
  146. void ControlMainWindow  (ControlHandle        whichControl,
  147.                          short                whichPart,
  148.                          Point                where)
  149. {
  150.     Rect            bounds;
  151.  
  152.     if ((whichControl == (**(cur->RemindersHandle)).vScroll)
  153.     ||  (whichControl == (**(cur->RemindersHandle)).hScroll)) {
  154.         if (LClick (where, 0, cur->RemindersHandle)) {
  155.             /*double click in scroll bar*/
  156.         }
  157.     }
  158.     if (whichControl == cur->AddHandle) {
  159.         if (TrackButton (cur->AddHandle, where)) {
  160.             DoAddButton ();
  161.         }
  162.     }
  163.     if (whichControl == cur->EditHandle) {
  164.         if (TrackButton (cur->EditHandle, where)) {
  165.             DoEditButton ();
  166.         }
  167.     }
  168.     if (whichControl == cur->DeleteHandle) {
  169.         if (TrackButton (cur->DeleteHandle, where)) {
  170.             DoDeleteButton ();
  171.         }
  172.     }
  173.  
  174. } /*ControlMainWindow*/
  175.  
  176. /*----------*/
  177. void MouseInMainWindow    (Point        where,
  178.                          short        modifiers)
  179. {
  180.     Rect            bounds;
  181.  
  182.     if (PtInRect (where, &(**(cur->RemindersHandle)).rView)) {
  183.         if (LClick (where, modifiers, cur->RemindersHandle)) {
  184.             /*double click*/
  185.         }
  186.         if (GetListChoice (&cur->RemindersChoice, cur->RemindersHandle)) {
  187.             /* something is selected */
  188.         }
  189.     }
  190.  
  191. } /*MouseInMainWindow*/
  192.  
  193. /*----------*/
  194. void TypeInMainWindow   (char        ch)
  195. {
  196.     if (cur->text == nil) {
  197.         SysBeep (1);
  198.     } else {
  199.         TEKey (ch, cur->text);
  200.         cur->dirty = true;
  201.     }
  202. } /*TypeInMainWindow*/
  203.  
  204. /*----------*/
  205. void UpdateMainWindow (void)
  206. {
  207.     Rect            bounds;
  208.  
  209.     GetWRect (LogoPicture, &bounds);
  210.     DrawPictureID (PICT_Logo, bounds);
  211.     SetWFont (YearLabel);
  212.     GetWRect (YearLabel, &bounds);
  213.     TextIDBox (TEXT_Year, bounds);
  214.     SetWFont (RemindersLabelLabel);
  215.     GetWRect (RemindersLabelLabel, &bounds);
  216.     TextIDBox (TEXT_RemindersLabel, bounds);
  217.     SetWFont (RemindersList);
  218.     LUpdate (qd.thePort->visRgn, cur->RemindersHandle);
  219.     bounds = (**(cur->RemindersHandle)).rView;
  220.     InsetRect (&bounds, -1, -1);
  221.     FrameRect (&bounds);
  222.     SetWFont (AddButton);
  223.     Draw1Control (cur->AddHandle);
  224.     SetWFont (EditButton);
  225.     Draw1Control (cur->EditHandle);
  226.     SetWFont (DeleteButton);
  227.     Draw1Control (cur->DeleteHandle);
  228. } /*UpdateMainWindow*/
  229.  
  230. /*----------*/
  231. void ActivateMainWindow    (Boolean    activate)
  232. {
  233.     LActivate (activate, cur->RemindersHandle);
  234.  
  235. } /*ActivateMainWindow*/
  236.  
  237. /*----------*/
  238. void ResizeMainWindow    (void)
  239. {
  240.     /* application-specific code to resize items in window */
  241. } /*ResizeMainWindow*/
  242.  
  243. /*----------*/
  244. pascal void ScrollMainWindow    (short        newValue,
  245.                                  short        oldValue)
  246. {
  247.     /* application-specific code to scroll window */
  248. } /*ScrollMainWindow*/
  249.  
  250. /* MainWindow */
  251.